//import org.gblog.*
import grails.util.Environment
import org.apache.shiro.crypto.hash.Sha256Hash

class BootStrap {

    def init = { servletContext ->

    	switch(Environment.current){ 
            case Environment.DEVELOPMENT: 


            def admin = new ShiroUser(
                firstName: "mingxian",lastName:"xu",username:"admin",passwordHash: new Sha256Hash("password").toHex(),email:"xmx0632@gmail.com",additionalInfo:"aaa")
	        admin.addToPermissions("*:*")
	        admin.save()

            def admin_common = new ShiroUser(firstName: "jingtao",lastName:"hu",username:"user", passwordHash: new Sha256Hash("password").toHex(),email:"hu@gmail.com",additionalInfo:"bbb")
	        admin_common.addToPermissions("post:*")
	        admin_common.addToPermissions("comment:*")
	        admin_common.save()

	        break 

            case Environment.PRODUCTION : 
            def admin = new ShiroUser(firstName: "mingxian",lastName:"xu",username:"admin",passwordHash: new Sha256Hash("password").toHex(),email:"xmx0632@gmail.com",additionalInfo:"")
	        admin.addToPermissions("*:*")
	        admin.save()
	        
            break 
        }
    }
    def destroy = {
    }
}
